// Fill out your copyright notice in the Description page of Project Settings.


#include "UI/Widget/SSlateDemoSlateBaseWidget.h"
#include "SlateOptMacros.h"
#include "Widgets/Layout/SBorder.h"
#include "Widgets/Layout/SScrollBox.h"
#include "Widgets/Layout/SGridPanel.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Input/SButton.h"
#include <Widgets/Layout/SSpacer.h>
#include <UObject/NoExportTypes.h>
#include <Widgets/Images/SImage.h>
#include <EditorStyleSet.h>
#include <Styling/SlateColor.h>
#include <Widgets/Input/SEditableTextBox.h>
#include "Widgets/Colors/SColorBlock.h"
#include <Widgets/Layout/SConstraintCanvas.h>
#include "Widgets/Images/SThrobber.h"
#include "Widgets/Input/SSpinBox.h"
#include "Widgets/Notifications/SProgressBar.h"
#include "Widgets/Input/SSlider.h"
#include "UI/Style/SlateDemoManager.h"
#include "UI/Style/SlateDemoWidgetStyle.h"
#include "Widgets/Images/SSpinningImage.h"
#include "Widgets/Input/SMultiLineEditableTextBox.h"
#include "Widgets/Views/STableViewBase.h"
#include "Widgets/Views/STableRow.h"
#include "FTestData.h"
#include "Widgets/Input/SNumericEntryBox.h"
#include "Widgets/Text/SInlineEditableTextBlock.h"
#include "../Plugins/FX/Niagara/Source/NiagaraEditor/Public/NiagaraEditorStyle.h"
#include "SRadioBox.h"
#include "Widgets/Layout/SBackgroundBlur.h"

float FRand(const float Min, const float Max)
{
	return Min + (Max - Min) * (rand() / (float)RAND_MAX);
}


BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION

void SSlateDemoSlateBaseWidget::Construct(const FArguments& InArgs)
{
	const FSlateBrush* MyNodeIcon = FCoreStyle::Get().GetBrush(TEXT("TrashCan"));
	BarValue = 0;
	FText st = FText::FromString(TEXT("本"));
	ToolbarStyle = &SlateDemoManager::Get().GetWidgetStyle<FSlateDemoStyle>("SlateDemoStyle_BP");
	ChildSlot
	[
		SNew(SBorder)
		.BorderImage(FCoreStyle::Get().GetBrush("ToolPanel.GroupBorder"))
		[
			SNew(SScrollBox)
			+ SScrollBox::Slot()
			.Padding(5.0f)
			[
				SNew(SGridPanel)
				.FillColumn(0, 0.1f)
				.FillColumn(1, 0.9f)
#pragma region SBorder(边框)
				// SBorder
				+ SGridPanel::Slot(0, 0)
				[
					SAssignNew(ceshi, STextBlock)
					.Text(FText::FromString(TEXT("SBorder")))
					.ToolTipText(FText::FromString(TEXT("边框控件")))
				]
				+ SGridPanel::Slot(1, 0)
				[
					SNew(SBorder)
					[
						SAssignNew(Space, SSpacer)
						//这里控件的宽度不会影响到父控件,
						//因为父控件的宽度是收到SGridPanel的影响,为软件总宽度的一半 参照
						//SNew(SGridPanel)
						//.FillColumn(0, 0.1f)
						//.FillColumn(1, 0.9f)
						//但是高度是可以控制的
						.Size(FVector2D(100.0f, 50.0f))
					]
				]
#pragma endregion
#pragma region SButton(按钮)
				//这里是按钮的操作DEMO
				+ SGridPanel::Slot(0, 1)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("SButton")))
					.ToolTipText(FText::FromString(TEXT("按钮")))
				]
				+ SGridPanel::Slot(1, 1)
				[
					SNew(SBorder).HAlign(HAlign_Fill)
					[
						SNew(SHorizontalBox)
						+ SHorizontalBox::Slot()
						  .Padding(2.0f, 5.0f) //这种写法代表左右间距2像素,上下间距5像素
						  .AutoWidth() //自动宽度代表子控件的尺寸由子控件自己来决定,不受父控件的影响
						[
							SAssignNew(SColorbtn, SButton)
							.VAlign(VAlign_Center) //设置垂直布局
							.HAlign(HAlign_Center) //设置水平布局
							.ButtonColorAndOpacity(FLinearColor::Blue) //设置按钮的颜色
							.OnClicked(this, &SSlateDemoSlateBaseWidget::ColorChangeBtn) //按钮点击事件
							.ToolTipText(FText::FromString(TEXT("改变颜色的按钮"))) //提示标签
							.ContentPadding(2.f) //设置内边距
							[
								SNew(SImage)
								.ColorAndOpacity(FLinearColor(0.5f, 0.2f, 0.7f))
							]
						]
						+ SHorizontalBox::Slot()
						  .Padding(5.0f) //内边距//这种写法代表子控件的上下左右边框都间隔5个像素
						  .FillWidth(0.1f) //所占空间的百分比
						[
							SAssignNew(SEnablebtn, SButton) //Sbuttons本身不带字符居中的设置,如果想要这种功能,只能嵌入STextBlock,
							.Text(FText::FromString(TEXT("OK")))
						]
						+ SHorizontalBox::Slot()
						  .Padding(1.0f, 2.0f, 3.0f, 4.0f) //左上右下的边距
						  .FillWidth(0.3f) //所占空间的百分比
						[
							SAssignNew(SSetEnablebtn, SButton).Text(FText::FromString(TEXT("设置了系统自定义的按钮样式")))
							                                  .ButtonStyle(FEditorStyle::Get(), "FlatButton") //按钮样式
							                                  .OnClicked(this, &SSlateDemoSlateBaseWidget::SetBtnEnable)
							                                  //按钮点击事
							                                  .ContentPadding(2.f)
							[
								SNew(SImage).Image(&ToolbarStyle->NormalBtn)
							]
						]
						+ SHorizontalBox::Slot()
						  .Padding(1.0f, 2.0f, 3.0f, 4.0f) //左上右下的边距
						  .FillWidth(0.3f) //所占空间的百分比
						[
							SAssignNew(SSetEnablebtn, SButton).Text(FText::FromString(TEXT("设置了自定义样式的按钮")))
							                                  .ButtonStyle(&ToolbarStyle->BtnStyle) //按钮样式
							                                  .OnClicked(this, &SSlateDemoSlateBaseWidget::SetBtnEnable)
							//按钮点击事
						]
					]
				]
#pragma endregion
#pragma region STextBlock(文本块)
				+ SGridPanel::Slot(0, 2)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("STextBlock")))
					.ToolTipText(FText::FromString(TEXT("文本块")))
				]
				+ SGridPanel::Slot(1, 2)
				[
					SNew(STextBlock)
					.TextStyle(FCoreStyle::Get(), "NormalUnderlinedText") //带下划线
					.Font(FCoreStyle::GetDefaultFontStyle("Bold", 20)) //字体和大小
					.Text(FText::FromString(TEXT("文本块"))) //要显示的字符串
					.ColorAndOpacity(FLinearColor::Red) //文本颜色
					.Justification(ETextJustify::Center) //对齐方式
					.ShadowOffset(FVector2D::UnitVector) //阴影
					.ShadowColorAndOpacity(FLinearColor::Green) //阴影的颜色
					.HighlightColor(FLinearColor::Gray) //高亮背景颜色
					.HighlightText(st) //需要高亮的字体,这里需要高亮的字体是'本'
				]
#pragma endregion
#pragma region SImage(图片)
				+ SGridPanel::Slot(0, 3)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("SImage")))
					.ToolTipText(FText::FromString(TEXT("图片")))
				]
				+ SGridPanel::Slot(1, 3)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot()
					.AutoWidth() //自动宽度代表子控件的尺寸由子控件自己来决定,不受父控件的影响
					[
						SNew(SImage)
						.Image(MyNodeIcon)
					]
					+ SHorizontalBox::Slot()
					  .Padding(5.0f, 0.0f)
					  .AutoWidth() //自动宽度代表子控件的尺寸由子控件自己来决定,不受父控件的影响
					[
						SNew(SImage)
						.ColorAndOpacity(FLinearColor(1, 1, 1, 1).HSVToLinearRGB())
					]
					+ SHorizontalBox::Slot()
					  .Padding(5.0f, 0.0f)
					  .AutoWidth() //自动宽度代表子控件的尺寸由子控件自己来决定,不受父控件的影响
					[
						SAssignNew(SColorimg, SImage)
						.Image(MyNodeIcon)
						.ColorAndOpacity(FLinearColor::Green)
					]
					+ SHorizontalBox::Slot()
					  .Padding(5.0f, 0.0f)
					  .AutoWidth() //自动宽度代表子控件的尺寸由子控件自己来决定,不受父控件的影响
					[
						SNew(SButton)
						.OnClicked(this, &SSlateDemoSlateBaseWidget::ColorChangeBtn) //按钮点击事件
						.Text(FText::FromString(TEXT("点我改变图片颜色")))
					]
				]
#pragma endregion
#pragma region SColorBlock(色块)
				+ SGridPanel::Slot(0, 4)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("SColorBlock")))
					.ToolTipText(FText::FromString(TEXT("色块")))
				]
				+ SGridPanel::Slot(1, 4)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot().AutoWidth().Padding(5)
					[
						SNew(SColorBlock)
						.Size(FVector2D(50, 50))
						.IgnoreAlpha(true) //不使用透明度
						.Color(FLinearColor(1.0f, 0.0f, 0.0f, 0.5f))
					]
					+ SHorizontalBox::Slot().AutoWidth().Padding(5)
					[
						SNew(SColorBlock)
						.Size(FVector2D(50, 50))
						.Color(FLinearColor(1.0f, 0.0f, 0.0f, 0.5f))
					]
					+ SHorizontalBox::Slot().AutoWidth().Padding(5)
					[
						SNew(SColorBlock)
						.Size(FVector2D(50, 50))
						.Color(FLinearColor(1.0f, 0.0f, 0.0f, 0.5f))
						.ShowBackgroundForAlpha(true) //在透明的情况下不显示背景
					]
				]
#pragma endregion
#pragma region SBox(指定子控件大小的控件)
				+ SGridPanel::Slot(0, 5)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("SBox")))
					.ToolTipText(FText::FromString(TEXT("尺寸盒子")))
				]
				+ SGridPanel::Slot(1, 5)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot()
					.AutoWidth()
					[
						SNew(SBox)
						.WidthOverride(150.f) //子控件的宽度
						.HeightOverride(100.f) //子控件的高度
						.MaxDesiredHeight(300.f) //最大高度
						.MinDesiredHeight(100.f) //最小高度
						.MaxDesiredWidth(300.f) //最大宽度
						.MinDesiredWidth(100.f) //最小宽度
						[
							SNew(SButton)
							.Text(FText::FromString(TEXT("被Sbox限定尺寸的按钮")))
						]
					]
					+ SHorizontalBox::Slot()
					.HAlign(HAlign_Fill)
					[
						SNew(SBox)
						.HAlign(HAlign_Left) //这种方式是选用子控件的大小并再SBox中进行左居中对齐
						.VAlign(VAlign_Fill)
						.Padding(FMargin(10.f, 0.f, 10.f, 0.f))
						[
							SNew(SButton)
							.ButtonColorAndOpacity(FLinearColor::Green)
							.Text(FText::FromString(TEXT("选择填充方式的按钮")))
						]
					]
				]
#pragma endregion
#pragma region SHorizontalBox(水平布局)
				+ SGridPanel::Slot(0, 6)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("SHorizontalBox")))
					.ToolTipText(FText::FromString(TEXT("水平布局")))
				]
				+ SGridPanel::Slot(1, 6)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot()
					.FillWidth(0.3f)
					[
						SNew(SButton)
						.Text(FText::FromString(TEXT("30% Width")))
					]
					+ SHorizontalBox::Slot()
					.FillWidth(0.7f)
					[
						SNew(SButton)
						.Text(FText::FromString(TEXT("70% Width")))
						.ButtonColorAndOpacity(FLinearColor::Green)
					]
					+ SHorizontalBox::Slot()
					.AutoWidth()
					[
						SNew(SButton)
						.ButtonColorAndOpacity(FLinearColor::White)
						.Text(FText::FromString(TEXT("AutoWidth这里的宽度是该按钮的宽度")))
					]
				]
#pragma endregion
#pragma region SEditableTextBox(可编辑文本框)
				+ SGridPanel::Slot(0, 7)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("SEditableTextBox")))
					.ToolTipText(FText::FromString(TEXT("可编辑文本框")))
				]
				+ SGridPanel::Slot(1, 7)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Center).Padding(5)
					[
						SNew(SEditableTextBox)
						.MinDesiredWidth(400) //控件的最小宽度
						.HintText(FText::FromString(TEXT("普通的输入框")))
						.SelectAllTextWhenFocused(true)
					]
					+ SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Center).Padding(5)
					[
						SNew(SEditableTextBox)
						.Text(FText::FromString(TEXT("只读类型")))
						.Font(FCoreStyle::GetDefaultFontStyle("Regular", 20))
						.IsReadOnly(true) //只读属性
						.HintText(FText::FromString(TEXT("Hint Text")))
					]
					+ SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Center).Padding(5)
					[
						SNew(SEditableTextBox)
						.Text(FText::FromString(TEXT("美化的输入框")))
						.Font(FCoreStyle::GetDefaultFontStyle("Bold", 40))
						.RevertTextOnEscape(true)
						.BackgroundColor(FLinearColor::Blue)
					]
					+ SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Center).VAlign(VAlign_Center).Padding(5)
					[
						SAssignNew(NumericInput, SEditableTextBox).OnTextCommitted_Lambda(
							                                          [this](const FText& InText,
							                                                 ETextCommit::Type InCommitType)
							                                          {
								                                          //如果不加判断,当按下回车失去焦点时,会触发两次该事件,一次时按下回车键触发的另外一次时失去焦点时触发的
								                                          if (InCommitType == ETextCommit::OnEnter)
									                                          GEngine->AddOnScreenDebugMessage(
										                                          -1, 10, FColor::Yellow,
										                                          (TEXT(
											                                          "NumericInput OnTextCommitted_Lambda")));
							                                          })
						                                          .OnTextChanged(
							                                          this,
							                                          &SSlateDemoSlateBaseWidget::OnNumericInputTextChanged)
						                                          .RevertTextOnEscape(true)
						                                          .HintText(FText::FromString(TEXT("数字模式")))
					]
					+ SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Center).VAlign(VAlign_Center).Padding(5)
					[
						SNew(SEditableTextBox)
					.IsPassword(true)
					.RevertTextOnEscape(true)
					.MinDesiredWidth(400) //控件的最小宽度
					.HintText(FText::FromString(TEXT("密码模式")))
					]
					+ SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Center).VAlign(VAlign_Center).Padding(5)
					[
						SNew(SInlineEditableTextBlock)
					.Font(FCoreStyle::GetDefaultFontStyle("Regular", 12))
					.Text(FText::FromString(TEXT("选中输入")))
					]
				]
#pragma endregion
#pragma region SComboBox(下拉菜单)
				+ SGridPanel::Slot(0, 8)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SComboBox")))
				.ToolTipText(FText::FromString(TEXT("下拉菜单")))
				]
				+ SGridPanel::Slot(1, 8)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot().AutoWidth()
					[
						SNew(SBox).MaxDesiredWidth(100).WidthOverride(100)
						[
							SAssignNew(SelectorComboBox, SComboBox<TSharedPtr<FString> >)
							.OptionsSource(&ComboBoxOptions)
							.OnSelectionChanged(this, &SSlateDemoSlateBaseWidget::SwitchComboToOptionSet) //选项改变时触发
							.OnGenerateWidget(this, &SSlateDemoSlateBaseWidget::HandleComboBoxGenerateWidget) //列表的回调
							[
								SNew(STextBlock)
								.Text(this, &SSlateDemoSlateBaseWidget::HandleSelectorComboBoxText) //按钮中显示的选项
							]
						]
					]
				]
#pragma endregion
#pragma region CheckBox(单选框)
				+ SGridPanel::Slot(0, 9)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("CheckBox")))
				.ToolTipText(FText::FromString(TEXT("单选框")))
				]
				+ SGridPanel::Slot(1, 9)
				[
					SAssignNew(SCBox, SCheckBox)
				.IsChecked(false)
				.OnCheckStateChanged_Lambda([](ECheckBoxState CheckState)
					                            {
						                            UE_LOG(LogNet, Log, TEXT("SCheckBox"));
					                            })
					[
						SNew(STextBlock)
						.Text(FText::FromString(TEXT("单选框")))
					]
				]
#pragma endregion
#pragma region CheckBox复选框用法
				+ SGridPanel::Slot(0, 10)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("CheckBox复选框用法")))
				.ToolTipText(FText::FromString(TEXT("复选框")))
				]
				+ SGridPanel::Slot(1, 10)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot()
					[
						SNew(SVerticalBox)
						+ SVerticalBox::Slot()
						.AutoHeight()
						[
							CreateRadioButton(FText::FromString(TEXT("复选框1")), Radio0)
						]
						+ SVerticalBox::Slot()
						.AutoHeight()
						[
							CreateRadioButton(FText::FromString(TEXT("复选框2")), Radio1)
						]
						+ SVerticalBox::Slot()
						.AutoHeight()
						[
							CreateRadioButton(FText::FromString(TEXT("复选框3")), Radio2)
						]
					]
					+ SHorizontalBox::Slot().AutoWidth()
					[
						SNew(STextBlock)
						.Text(FText::FromString(TEXT("修改SCheckBox源码实现的复选框功能")))
					]
					+ SHorizontalBox::Slot()
					[
						SNew(SVerticalBox)
						+ SVerticalBox::Slot()
						[
							SNew(SRadioBox)
						.IsChecked(ECheckBoxState::Checked)
						.Style(FCoreStyle::Get(), "RadioButton")
						.group(&RadioBoxGrop) //必须要加组,否则和checkbox的功能一样
							[
								SNew(STextBlock)
								.Text(FText::FromString(TEXT("1")))
							]
						]
						+ SVerticalBox::Slot()
						[
							SNew(SRadioBox)
						.Style(FCoreStyle::Get(), "RadioButton")
						.group(&RadioBoxGrop) //必须要加组,否则和checkbox的功能一样
							[
								SNew(STextBlock)
								.Text(FText::FromString(TEXT("2")))
							]
						]
					]
				]
#pragma endregion
#pragma region SConstraintCanvas(子控件可以任意摆放的容器)
				+ SGridPanel::Slot(0, 11)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SConstraintCanvas")))
				.ToolTipText(FText::FromString(TEXT("任意摆放的容器")))
				]
				+ SGridPanel::Slot(1, 11)
				[
					SNew(SConstraintCanvas)
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0)) //锚点,这里需要设置为0
					  .Alignment(FVector2D(0.0, 0.0)) //轴(设置为0,0则代表控件的坐上角坐标为起始原点,如果设置为1,1 则代表控件的右下角为其实原点)
					  .Offset(FMargin(0, 0, 50, 50))
					[
						SNew(SColorBlock)
					.Size(FVector2D(50, 50))
					.IgnoreAlpha(true) //不使用透明度
					.Color(FLinearColor(1.0f, 0.0f, 0.0f, 0.5f))
					]
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(50, 50, 50, 50))
					[
						SNew(SColorBlock)
					.Size(FVector2D(50, 50))
					.IgnoreAlpha(true) //不使用透明度
					.Color(FLinearColor(0.0f, 1.0f, 0.0f, 0.5f))
					]
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(100, 0, 50, 50))
					[
						SNew(SColorBlock)
					.Size(FVector2D(50, 50))
					.IgnoreAlpha(true) //不使用透明度
					.Color(FLinearColor(0.0f, 0.0f, 1.0f, 0.5f))
					]
				]
#pragma endregion
#pragma region SOverlay(z序覆盖类)
				+ SGridPanel::Slot(0, 12)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SOverlay")))
				.ToolTipText(FText::FromString(TEXT("覆盖类控件")))
				]
				+ SGridPanel::Slot(1, 12)
				[
					SNew(SConstraintCanvas)
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(0, 0, 50, 50))
					[
						SNew(SOverlay)
						+ SOverlay::Slot().HAlign(HAlign_Fill).VAlign(VAlign_Fill)
						[
							SNew(SColorBlock)
							.Color(FLinearColor(1.0f, 0.0f, 0.0f, 1.0f))
						]
						+ SOverlay::Slot().Padding(5.f).HAlign(HAlign_Fill).VAlign(VAlign_Fill)
						[
							SNew(STextBlock)
							.Text(FText::FromString(TEXT("SOverlay")))
						]
						/*+ SOverlay::Slot().Padding(10.f).HAlign(HAlign_Fill).VAlign(VAlign_Fill)
						[
							SNew(SColorBlock)
							.Color(FLinearColor(0.0f, 0.0f, 1.0f, 0.5f))
						]*/
					]
				]
#pragma endregion
#pragma region SSpinningImage(旋转图片)
				+ SGridPanel::Slot(0, 13)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SSpinningImage")))
				.ToolTipText(FText::FromString(TEXT("旋转图片,让图片单一旋转")))
				]
				+ SGridPanel::Slot(1, 13)
				  .HAlign(HAlign_Left)
				  .Padding(0.0f, 5.0f)
				[
					SNew(SSpinningImage)
					.Image(&ToolbarStyle->runimg)
				]
#pragma endregion
#pragma region SCircularThrobber(旋转图片高级版)
				+ SGridPanel::Slot(0, 14)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SCircularThrobber")))
				.ToolTipText(FText::FromString(TEXT("高级旋转图片,给定一个图片让他组成很多个点进行旋转")))
				]
				+ SGridPanel::Slot(1, 14)
				[
					SNew(SConstraintCanvas)
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(0, 0, 50, 50))
					[
						SNew(SCircularThrobber)
					.PieceImage(&ToolbarStyle->runimg)
					.NumPieces(10)
					.Radius(20)
					.Period(1.f)
					]
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(50, 0, 50, 50))
					[
						SNew(SCircularThrobber)
					.NumPieces(10)
					.Radius(20).Period(1.f)
					]
				]
#pragma endregion
#pragma region SSpinBox(数值调整控件)
				+ SGridPanel::Slot(0, 15)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SSpinBox")))
				.ToolTipText(FText::FromString(TEXT("数字调整控件")))
				]
				+ SGridPanel::Slot(1, 15)
				[
					SNew(SConstraintCanvas)
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(0, 0, 150, 20))
					[
						SAssignNew(SpinBox, SSpinBox<int32>)
					.Value(0)
					.OnValueChanged(this, &SSlateDemoSlateBaseWidget::WidgetValueChange)
					.MinValue(0)
					.MaxValue(100)
					]
				]
#pragma endregion
#pragma region SProgressBar(进度条)
				+ SGridPanel::Slot(0, 16)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SProgressBar")))
				.ToolTipText(FText::FromString(TEXT("进度条")))
				]
				+ SGridPanel::Slot(1, 16)
				[
					SNew(SVerticalBox)
					+ SVerticalBox::Slot()
					[
						SNew(SProgressBar)
						//.Percent(this, &SSlateDemoSlateBaseWidget::ProgressBarValue)
						.FillColorAndOpacity(FLinearColor::Green)
					]
					+ SVerticalBox::Slot()
					[
						SNew(SProgressBar)
					]
				]
#pragma endregion
#pragma region SSlider(滑动条)
				+ SGridPanel::Slot(0, 17)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SSlider")))
				.ToolTipText(FText::FromString(TEXT("滑块")))
				]
				+ SGridPanel::Slot(1, 17)
				[
					SNew(SBox)
				.HeightOverride(100.0f)
				.WidthOverride(150.0f)
					[
						SNew(SConstraintCanvas)
						+ SConstraintCanvas::Slot()
						  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
						  .Alignment(FVector2D(0.0, 0.0))
						  .Offset(FMargin(0, 0, 150, 20))
						[
							SAssignNew(SliderHor, SSlider)
						.OnValueChanged_Lambda([this](float value)
							                              {
								                              BarValue = value * 100;
								                              SliderVer->SetValue(value);
								                              SpinBox->SetValue(BarValue);
							                              })
						.Orientation(Orient_Horizontal)
						.Value(0.f)
						]
						+ SConstraintCanvas::Slot()
						  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
						  .Alignment(FVector2D(0.0, 0.0))
						  .Offset(FMargin(200, 0, 20, 100))
						[
							SAssignNew(SliderVer, SSlider)
						.OnValueChanged_Lambda([this](float value)
							                              {
								                              BarValue = value * 100;
								                              SliderHor->SetValue(value);
								                              SpinBox->SetValue(BarValue);
							                              })
						.Orientation(Orient_Vertical).SliderHandleColor(FLinearColor::Red).SliderBarColor(
								                              FLinearColor::Blue)
						.Value(0.f)
						]
					]
				]
#pragma endregion
#pragma region SSpacer(占位控件)
				+ SGridPanel::Slot(0, 18)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SSpacer")))
				.ToolTipText(FText::FromString(TEXT("占位控件,在这里的DEMO中空白区域是占位控件")))
				]
				+ SGridPanel::Slot(1, 18)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot()
					[
						SNew(SColorBlock).Color(FLinearColor(1.0f, 0.f, 0.f))
					]
					+ SHorizontalBox::Slot().AutoWidth()
					[
						SNew(SSpacer)
						.Size(FVector2D(50, 50))
					]
					+ SHorizontalBox::Slot()
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 1.f, 0.f))
					]
				]
#pragma endregion
#pragma region SMultiLineEditableTextBox(多行可编辑文本)
				+ SGridPanel::Slot(0, 19)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SMultiLineEditableTextBox")))
				.ToolTipText(FText::FromString(TEXT("多行可编辑文本")))
				]
				+ SGridPanel::Slot(1, 19)
				[
					SNew(SConstraintCanvas)
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(0, 0, 100, 150))
					[
						SNew(SMultiLineEditableTextBox)
					.Text(FText::FromString(TEXT("这是一个多行可编辑文本,默认情况下已经提供了滚动条")))
					.AutoWrapText(true)
					]
				]
#pragma endregion
#pragma region SGridPanel(网格布局)
				+ SGridPanel::Slot(0, 20)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SGridPanel")))
				.ToolTipText(FText::FromString(TEXT("网格布局,可以设置网格大小的占比")))
				]
				+ SGridPanel::Slot(1, 20)
				[
					SNew(SGridPanel)
				.FillColumn(0, 1.f)
				.FillColumn(1, 2.f)
				.FillColumn(2, 3.f)
				.FillRow(0, 1.f)
				.FillRow(1, 2.f)
				.FillRow(2, 3.f)
					+ SGridPanel::Slot(0, 0)
					[
						SNew(SColorBlock).Color(FLinearColor(1.0f, 0.0f, 0.0f))
					]
					+ SGridPanel::Slot(0, 1)
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 1.0f, 0.0f))
					]
					+ SGridPanel::Slot(0, 2)
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 0.0f, 1.0f))
					]
					+ SGridPanel::Slot(1, 0)
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 1.0f, 0.0f))
					]
					+ SGridPanel::Slot(1, 1)
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 0.0f, 1.0f))
					]
					+ SGridPanel::Slot(1, 2)
					[
						SNew(SColorBlock).Color(FLinearColor(1.0f, 0.0f, 0.0f))
					]
					+ SGridPanel::Slot(2, 0)
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 0.0f, 1.0f))
					]
					+ SGridPanel::Slot(2, 1)
					[
						SNew(SColorBlock).Color(FLinearColor(1.0f, 0.0f, 0.0f))
					]
					+ SGridPanel::Slot(2, 2)
					[
						SNew(SColorBlock).Color(FLinearColor(0.0f, 1.0f, 0.0f))
					]
				]
#pragma endregion
#pragma region Splitter(百分比布局)
				+ SGridPanel::Slot(0, 21)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("Splitter")))
				.ToolTipText(FText::FromString(TEXT("百分比布局 此布局两两之间可以通过中间的分隔符进行拖拽")))
				]
				+ SGridPanel::Slot(1, 21).Padding(0.f, 5.f, 0.f, 0.f)
				[
					SNew(SConstraintCanvas)
					+ SConstraintCanvas::Slot()
					  .Anchors(FAnchors(0.0, 0.0, 0.0, 0.0))
					  .Alignment(FVector2D(0.0, 0.0))
					  .Offset(FMargin(0, 0, 2000, 200))
					[
						SNew(SSplitter)
					.Orientation(Orient_Vertical).PhysicalSplitterHandleSize(1.f)
						+ SSplitter::Slot().Value(3.f)
						[
							SNew(SSplitter).PhysicalSplitterHandleSize(1.f)
							               .Orientation(Orient_Horizontal)
							+ SSplitter::Slot().Value(1.f)
							[
								SNew(SColorBlock).Color(FLinearColor(1.0f, 0.0, 0.0))
							]
							+ SSplitter::Slot().Value(1.f)
							[
								SNew(SColorBlock).Color(FLinearColor(1.0f, 1.0, 0.0))
							]
							+ SSplitter::Slot().Value(3.f)
							[
								SNew(SColorBlock).Color(FLinearColor(0.0f, 1.0, 1.0))
							]
						]
						+ SSplitter::Slot().Value(2.f)
						[
							SNew(SSplitter).PhysicalSplitterHandleSize(1.f)
							               .Orientation(Orient_Vertical)
							+ SSplitter::Slot().Value(1.f)
							[
								SNew(SColorBlock).Color(FLinearColor(1.0f, 0.0, 0.0))
							]
							+ SSplitter::Slot().Value(1.f)
							[
								SNew(SColorBlock).Color(FLinearColor(1.0f, 1.0, 0.0))
							]
						]
					]
				]
#pragma endregion
#pragma region SMyConstraintCanvas&SMySpinBox(自定义控件)
				+ SGridPanel::Slot(0, 22)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SMyConstraintCanvas&SMySpinBox")))
				.ToolTipText(FText::FromString(TEXT("自定义数值控件,需要搭配自定义的容器控件一起使用")))
				]
				+ SGridPanel::Slot(1, 22).Padding(0.f, 5.f, 0.f, 0.f)
				[
					SAssignNew(canvas, SMyConstraintCanvas)
					+ SMyConstraintCanvas::Slot()
					.Offset(FMargin(300, 0, 300, 20))
					[
						SAssignNew(myspinbox, SMySpinBox<uint16>)
					.MinValue(0)
					.MaxValue(100)
					.Value(10)
					.OnChangeSize(this, &SSlateDemoSlateBaseWidget::ChangeMySpinBoxSize)
					]
				]
#pragma endregion
#pragma region SBackgroundBlur(背景模糊控件)
				+ SGridPanel::Slot(0, 23)
				[
					SNew(STextBlock)
				.Text(FText::FromString(TEXT("SBackgroundBlur")))
				.ToolTipText(FText::FromString(TEXT("背景模糊控件")))
				]
				+ SGridPanel::Slot(1, 23).Padding(0.f, 5.f, 0.f, 0.f)
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot().AutoWidth()
					[
						SNew(SOverlay)
						+ SOverlay::Slot()
						[
							SNew(SImage)
							.Image(MyNodeIcon)
						]
						+ SOverlay::Slot()
						[
							SNew(SHorizontalBox)
							+ SHorizontalBox::Slot().FillWidth(1)
							[
								SNew(SBackgroundBlur).BlurStrength(5.0)
							]
							+ SHorizontalBox::Slot().FillWidth(1)
							[
								SNew(SSpacer)
							]
						]
					]
					+ SHorizontalBox::Slot().FillWidth(1)
					[
						SNew(SSpacer)
					]
				]

#pragma endregion
			]
		]
	];

	ComboBoxInit(); //对Combo进行初始化
}

END_SLATE_FUNCTION_BUILD_OPTIMIZATION


FReply SSlateDemoSlateBaseWidget::ColorChangeBtn()
{
	SColorbtn->SetContent(
		SNew(SImage)
		.ColorAndOpacity(FLinearColor(FRand(0.0f, 1.0f), FRand(0.0f, 1.0f), FRand(0.0f, 1.0f)))
	);
	SColorimg->SetColorAndOpacity(FLinearColor(FRand(0.0f, 1.0f), FRand(0.0f, 1.0f), FRand(0.0f, 1.0f)));
	ceshi->SetText(FText::FromString(TEXT("Slate高级控件")));
	return FReply::Handled();
}

FReply SSlateDemoSlateBaseWidget::SetBtnEnable()
{
	if (SEnablebtn->IsEnabled())
		SEnablebtn->SetEnabled(false);
	else
		SEnablebtn->SetEnabled(true);
	return FReply::Handled();
}

void SSlateDemoSlateBaseWidget::OnNumericInputTextChanged(const FText& NewText)
{
	const FText Error = (NewText.IsNumeric())
		                    ? FText::GetEmpty()
		                    : FText::Format(FText::FromString(TEXT("'{0}' 不是纯数字")), NewText);

	//ErrorText->SetError(Error);
	NumericInput->SetError(Error);
}

void SSlateDemoSlateBaseWidget::ComboBoxInit()
{
	ComboBoxOptions.Empty();
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("One"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Two"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Three"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Four"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Five"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Six"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Seven"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Eight"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Nine"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Ten"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Eleven"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Twelve"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Thirteen"))));
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("Fourteen"))));
	SelectorComboBox->RefreshOptions();
	SelectorComboBox->SetSelectedItem(ComboBoxOptions[0]);
	SelectorComboBoxSelectedItem = ComboBoxOptions[0];
	ComboBoxOptions.Add(MakeShareable(new FString(TEXT("666666666666"))));
}

void SSlateDemoSlateBaseWidget::SwitchComboToOptionSet(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo)
{
	SelectorComboBoxSelectedItem = NewSelection;
}

TSharedRef<SWidget> SSlateDemoSlateBaseWidget::HandleComboBoxGenerateWidget(TSharedPtr<FString> InItem)
{
	return SNew(STextBlock)
		.Text(FText::FromString(*InItem));
}

FText SSlateDemoSlateBaseWidget::HandleSelectorComboBoxText() const
{
	return SelectorComboBoxSelectedItem.IsValid()
		       ? FText::FromString(*SelectorComboBoxSelectedItem)
		       : FText::GetEmpty();
}

TSharedRef<SWidget> SSlateDemoSlateBaseWidget::CreateRadioButton(const FText& RadioText, ERadioChoice RadioButtonChoice)
{
	return SNew(SCheckBox)
		.Style(FCoreStyle::Get(), "RadioButton")
		.IsChecked(this, &SSlateDemoSlateBaseWidget::HandleRadioButtonIsChecked, RadioButtonChoice)
		.OnCheckStateChanged(this, &SSlateDemoSlateBaseWidget::HandleRadioButtonCheckStateChanged, RadioButtonChoice)
	[
		SNew(STextBlock)
		.Text(RadioText)
	];
}

void SSlateDemoSlateBaseWidget::HandleRadioButtonCheckStateChanged(ECheckBoxState NewRadioState,
                                                                   ERadioChoice RadioThatChanged)
{
	if (NewRadioState == ECheckBoxState::Checked)
	{
		RadioChoice = RadioThatChanged;
	}
}

// Callback for determining whether a radio button is checked.
ECheckBoxState SSlateDemoSlateBaseWidget::HandleRadioButtonIsChecked(ERadioChoice ButtonId) const
{
	return (RadioChoice == ButtonId)
		       ? ECheckBoxState::Checked
		       : ECheckBoxState::Unchecked;
}

void SSlateDemoSlateBaseWidget::WidgetValueChange(int32 NewValue)
{
	BarValue = NewValue;
	SliderHor->SetValue((float)BarValue / 100.0);
	SliderVer->SetValue((float)BarValue / 100.0);
}

TOptional<float> SSlateDemoSlateBaseWidget::ProgressBarValue() const
{
	return (float)BarValue / 100.0;
}

void SSlateDemoSlateBaseWidget::ChangeMySpinBoxSize(const FMargin margin)
{
	canvas->OnChangeChildrenSize((TSharedPtr<SWidget>)myspinbox, margin);
}
